package at.jku.pervasive.gui.renderer;

import java.awt.Color;
import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

import at.jku.pervasive.Application;

public class TagIdColorRenderer extends DefaultListCellRenderer
{

	@Override
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
			boolean cellHasFocus)
	{
		Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
		String tagId = (String) value;
		if (value != null)
		{
			Color color = Application.getInstance().getColorForTagId(tagId);
			if (color != null)
				comp.setBackground(color.brighter());
		}
		return comp;
	}

}
